source("funcs_and_cons.R")
## ability and participation distribution

mom_ability <- fread(paste0(dir.generated,'matlab/Calibration/',calibration_version,'_abilityDistThreeFixC_mom.csv'))
mom_pf <- fread(paste0(dir.generated,'matlab/Calibration/',calibration_version,'_KrusellRobotsEach_mom.csv'))

sol_ability <- fread(paste0(dir.generated,'matlab/Calibration/',calibration_version,'_abilityDistThreeFixC_sol.csv'))
const <- fread(paste0(dir.raw,'constants.csv'))
part_share <- fread(paste0(dir.generated,'r/part_share.csv'))
inc <- fread(paste0(dir.generated,'r/mean_inc.csv'))

stats <- fread(paste0(dir.generated,'r/morg_sumstats_table.csv'))
stats.all <- fread(paste0(dir.generated,'r/morg_sumstats_all_table.csv'))

dat.emp_M <- rnd2(100*stats$empl.sh[stats$cat3=='svc'][1])
dat.emp_R <- rnd2(100*stats$empl.sh[stats$cat3=='rt'][1])
dat.emp_C <- rnd2(100*stats$empl.sh[stats$cat3=='abs'][1])

dat.w_M <- rnd2(stats$hrwage16.mean[stats$cat3=='svc'][1])
dat.w_R <- rnd2(stats$hrwage16.mean[stats$cat3=='rt'][1])
dat.w_C <- rnd2(stats$hrwage16.mean[stats$cat3=='abs'][1])

mod.part_0 <- rnd2(mom_ability$participation_rate_0[[1]]*100)
mod.K_B_rel_change <- rnd2(mom_ability$K_B_rel_change[[1]])
mod.part_M_change <- rnd2(mom_ability$part_M_change[[1]]*100)
mod.part_R_change <- rnd2(mom_ability$part_R_change[[1]]*100)
mod.part_C_change <- rnd2(mom_ability$part_C_change[[1]]*100)
mod.lab_inc_sh <- rnd2(mom_pf$labor_income_share_0[[1]]*100)
mod.price_elast_K_B <- rnd2(abs(mom_pf$K_B_rel_change[[1]]/mom_pf$Y_B_rel_change[[1]]))

mod.robot_inc_sh_lab <- rnd2(mom_pf$labor_share_in_labor_plus_robot_income_0[[1]]*100)
mod.M_share_in_labor_income <- rnd2(mom_pf$M_share_in_labor_income_0[[1]]*100)
mod.R_share_in_labor_income <- rnd2(mom_pf$R_share_in_labor_income_0[[1]]*100)

dat.price_elast_K_B <- rnd2((8.33 + 3.33)/2)

mod.emp_M <- rnd2(mom_ability$emp_M_0[[1]]*100)
mod.emp_R <- rnd2(mom_ability$emp_R_0[[1]]*100)
mod.emp_C <- rnd2(mom_ability$emp_C_0[[1]]*100)

mod.avg_wage_M <- rnd2(mom_ability$average_wage_M_0[[1]])
mod.avg_wage_R <- rnd2(mom_ability$average_wage_R_0[[1]])
mod.avg_wage_C <- rnd2(mom_ability$average_wage_C_0[[1]])

mod.avg_mtax <- rnd2(mom_ability$avg_mtax_incweighted[[1]]*100)

par.scale_inc <- sol_ability$scale_inc[1]

# avg. labor inc. in 1000 USD
mod.avg_labor_income <- rnd2(mom_ability$avg_labor_income[[1]] * par.scale_inc/1000) 
mod.transfer_lab_inc_share <- rnd2(mom_ability$transfer_lab_inc_share[[1]]*100)
dat.transfer_lab_inc_share <- rnd2(const$transfer_share_GDP[[1]]/const$labor_share[[1]]*100)

dat.part_change <- fread(paste0(dir.generated,'r/emp_change.csv'))

dat.part_M_change <- rnd2(dat.part_change$M*100)
dat.part_R_change <- rnd2(dat.part_change$R*100)
dat.part_C_change <- rnd2(dat.part_change$C*100)

mod.rob_sh_cap <- rnd2(mom_pf$robot_share_capital[1]*100)

dat.part_all <- rnd2(part_share$all[[1]]*100)
dat.avg_inc <-  rnd2(inc$mean[[1]]/1000)
dat.labor_share <- rnd2(const$labor_share[[1]]*100)
dat.M_share <-  rnd2(inc$M_share[[1]]*100)
dat.R_share <-  rnd2(inc$R_share[[1]]*100)
dat.robot_share <-  rnd2(const$robot_share[[1]]*100)
